program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  arr = array of integer;
var
  mass: array of arr;
  n, i, j: integer;
  f: boolean;
begin
  read (n);
  setlength (mass, n, n);
  for i := 0 to n - 1 do
    for j := 0 to n - 1 do
      read (mass[i, j]);
  for i := 0 to n - 1 do
    for j := i to n - 1 do
      if (mass[i, j]<>mass[j, i]) or (mass[i, i]=1) then
      begin
        f:= true;
        break;
      end;
  if (f) then
    write ('NO')
  else
    write ('YES');
      
end.
